package org.example.route.mapper;


import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.route.model.dto.CityDTO;
import org.example.route.model.dto.CityQueryDTO;
import org.example.route.model.pojo.City;

import java.util.List;

@Mapper
public interface CityMapper {

    @Select("select name from city where id = #{cityId}")
    String getCityNameById(Long cityId);

    @Insert("insert into city (name,province_id) values (#{name},#{provinceId})")
    void add(CityDTO cityDTO);

    List<City> list(CityQueryDTO cityQueryDTO);

    @Select("select * from city where id = #{id}")
    City getById(Long id);

    @Delete("delete from city where id = #{id}")
    void deleteById(Long id);

    @Select("select name from city where province_id = #{id}")
    List<City> getByProvinceId(Long id);
}
